package user;

import book.BookList;
import operation.*;


import java.util.Scanner;

public class NormalUser extends User {

    {
        super.operations = new Operation[]{
                new ExitOperation(),
                new BorrowOperation(),
                new ReturnOperation(),
                new FindOperation()
        };
    }

    public NormalUser(String name) {
        super(name);
    }

    @Override
    public int menu() {
        System.out.println(name + " 欢迎来到图书管理小练习!");
        System.out.println("**********************************************");
        System.out.println("1.借阅一本书");
        System.out.println("2.归还一本书");
        System.out.println("3.查找一本书");
        System.out.println("0.退出系统");
        System.out.println("**********************************************");
        System.out.println("请选择操作：");
        Scanner scanner = new Scanner(System.in);
        return scanner.nextInt();
    }

    @Override
    public void operation(int pos, BookList bookList) {
        Operation operation = this.getOperation(pos);
        if (operation != null) {
            operation.work(bookList);
        }
    }
}
